"use strict";
cc._RF.push(module, 'eacc3/Mc21Pf70wEEVJgFxk', 'main');
// src/main.js

"use strict";

var n = module.exports = {};
var t = module;

var i = require('define'),
    o = (require('AdsManagerJS'), require('ShareManagerJS')),
    a = require('GameDataManagerJS');

cc.Class({
  "extends": cc.Component,
  properties: {
    background: cc.Sprite,
    title_bg: cc.Sprite,
    gold_btn: cc.Button,
    audio_btn: cc.Button,
    share_btn: cc.Button,
    moregame_btn: cc.Button,
    begin_btn: cc.Button,
    rank_btn: cc.Button,
    skin_btn: cc.Button,
    rankNode: cc.Node,
    skinNode: cc.Node,
    gold_lab: cc.Label,
    gameBox: cc.Node
  },
  onLoad: function onLoad() {
    var e = this,
        t = cc.find("Canvas").getComponent(cc.Canvas);
    /*    
    cc.winSize.width / cc.winSize.height <= (750 / 1334).designScreen ? (t.fitHeight = !1, t.fitWidth = !0) : (t.fitHeight = !0, t.fitWidth = !1)/*, t.alignWithScreen();
    var n = cc.view.getDesignResolutionSize(),
        o = cc.director.getWinSize(),
        c = (o.width, n.width, o.height, n.height, cc.view.getVisibleSize()),
        s = c.width / c.height,
        r = s - 750 / 1334;
    if (console.log("  k= " + 750 / 1334 + " kWH= " + s), r > 0);
    else {
        var l = this.begin_btn.node.getPosition();
        l.y -= 400 * -r, this.begin_btn.node.setPosition(l), console.log("begin_btn - " + 400 * -r)
    }
    if (cc.sys.platform == cc.sys.IPHONE) {
        var g = cc.view.getFrameSize();
        if (2436 == g.width && 1125 == g.height || 1125 == g.width && 2436 == g.height) {
            var d = this.node.getComponent(cc.Canvas);
            d.fitHeight = !0, d.fitWidth = !0
        }
    }*/

    this.audioControl = cc.find("AudioControlNode").getComponent("AudioSourceControl"), this.mute = cc.find("AudioControlNode/AudioRes/audio").getComponent(cc.AudioSource);
    var u = a.getInstance().getcarskin();
    i.carskin = u;
    var h = a.getInstance().getgold();
    i.money = h, this.gold_lab.string = i.money, this.node.on("updatemoney", function () {
      e.updatemoney();
    });
  },
  updatemoney: function updatemoney() {
    this.gold_lab.string = i.money;
  },
  start: function start() {
    this.rankNode.active = !1, this.skinNode.active = !1, this.playAudio();
    var e = a.getInstance().getGameCompleteStars();
    this.submitScoreButtonFunc(e);
  },
  submitScoreButtonFunc: function submitScoreButtonFunc(e) {
    console.log(" main  提交 : " + e + " key= " + i.RankKey), console.log("不支持 提交得分 : " + e);
  },
  update: function update(e) {},
  gold_btnClick: function gold_btnClick() {
    this.playClick(), i.money += 50, a.getInstance().savegold(i.money), this.node.emit("updatemoney");
  },
  gold_btnCallback: function gold_btnCallback() {
    i.money += 50, a.getInstance().savegold(i.money), this.node.emit("updatemoney");
  },
  audio_btnClick: function audio_btnClick() {
    if (this.playClick(), 1 == i.music) {
      i.music = !1, this.mute.volume = 0;
      var e = this,
          t = "mute";
      cc.loader.loadRes(t, cc.SpriteFrame, function (t, n) {
        e.audio_btn.normalSprite = n, e.audio_btn.pressedSprite = n, e.audio_btn.hoverSprite = n;
      });
    } else {
      i.music = !0, this.mute.volume = 1;
      e = this, t = "music";
      cc.loader.loadRes(t, cc.SpriteFrame, function (t, n) {
        t ? cc.log("Completed with " + t.length + " errors") : (e.audio_btn.normalSprite = n, e.audio_btn.pressedSprite = n, e.audio_btn.hoverSprite = n);
      });
    }
  },
  other_btnClick: function other_btnClick() {
    this.playClick();
  },
  moregame_btnClick: function moregame_btnClick() {
    this.playClick();
  },
  begin_btnClick: function begin_btnClick() {
    this.playClick(), cc.director.loadScene("ChooseStageScene");
  },
  share_btnClick: function share_btnClick() {
    this.playClick(), this.main = cc.find("Canvas/main");
    a.getInstance().getTextById(17);
    o.getInstance().onShareGame("sharePic");
  },
  rank_btnClick: function rank_btnClick() {
    this.playClick(), this.main = cc.find("Canvas/main"), this.main.active = !1, this.rank = cc.find("Canvas/rankNode"), this.rank.active = !0;
  },
  skin_btnClick: function skin_btnClick() {
    this.main = cc.find("Canvas/main"), this.main.active = !1, this.skin = cc.find("Canvas/skinNode"), this.skin.active = !0, this.playClick();
  },
  back_btnClick: function back_btnClick() {
    cc.director.loadScene("main"), this.playClick();
  },
  playClick: function playClick() {
    this.audioControl && this.audioControl.playClick();
  },
  playAudio: function playAudio() {
    this.audioControl && this.audioControl.playAudio();
  }
});

cc._RF.pop();